package com.nmsl.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.nmsl.common.annotation.Log;
import com.nmsl.common.core.controller.BaseController;
import com.nmsl.common.core.domain.AjaxResult;
import com.nmsl.common.enums.BusinessType;
import com.nmsl.system.domain.Clinics;
import com.nmsl.system.service.IClinicsService;
import com.nmsl.common.utils.poi.ExcelUtil;
import com.nmsl.common.core.page.TableDataInfo;

/**
 * 诊所信息管理Controller
 * 
 * @author jin
 * @date 2025-02-14
 */
@RestController
@RequestMapping("/system/clinics")
public class ClinicsController extends BaseController
{
    @Autowired
    private IClinicsService clinicsService;

    /**
     * 查询诊所信息管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:clinics:list')")
    @GetMapping("/list")
    public TableDataInfo list(Clinics clinics)
    {
        startPage();
        List<Clinics> list = clinicsService.selectClinicsList(clinics);
        return getDataTable(list);
    }

    /**
     * 导出诊所信息管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:clinics:export')")
    @Log(title = "诊所信息管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Clinics clinics)
    {
        List<Clinics> list = clinicsService.selectClinicsList(clinics);
        ExcelUtil<Clinics> util = new ExcelUtil<Clinics>(Clinics.class);
        util.exportExcel(response, list, "诊所信息管理数据");
    }

    /**
     * 获取诊所信息管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:clinics:query')")
    @GetMapping(value = "/{clinicId}")
    public AjaxResult getInfo(@PathVariable("clinicId") Long clinicId)
    {
        return success(clinicsService.selectClinicsByClinicId(clinicId));
    }

    /**
     * 新增诊所信息管理
     */
    @PreAuthorize("@ss.hasPermi('system:clinics:add')")
    @Log(title = "诊所信息管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Clinics clinics)
    {
        return toAjax(clinicsService.insertClinics(clinics));
    }

    /**
     * 修改诊所信息管理
     */
    @PreAuthorize("@ss.hasPermi('system:clinics:edit')")
    @Log(title = "诊所信息管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Clinics clinics)
    {
        return toAjax(clinicsService.updateClinics(clinics));
    }

    /**
     * 删除诊所信息管理
     */
    @PreAuthorize("@ss.hasPermi('system:clinics:remove')")
    @Log(title = "诊所信息管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{clinicIds}")
    public AjaxResult remove(@PathVariable Long[] clinicIds)
    {
        return toAjax(clinicsService.deleteClinicsByClinicIds(clinicIds));
    }
}
